
#include "Minimap.h"
#include "World.h"
#include "Map.h"

#include <GL/gl.h>


Minimap::Minimap(Vector2D screen_pos, float size) :
    screen_pos(screen_pos), size(size) {

}

Minimap::~Minimap(){
}

void Minimap::render(void){
    Map *map = World::instance().getMap();
    float mwidth = map->getWidth();
    float mheight = map->getHeight();
    float xscale = size/mwidth;
    float yscale = size/mheight;

    std::vector<WorldObject*> world_objects = World::instance().getObjectsInVicinity(Vector2D(0.0f, 0.0f));


    glPushMatrix();
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glTranslatef(screen_pos.x, screen_pos.y, 0.0f);
    glScalef(xscale, yscale, 1.0f);

    map->renderMinimap();

    for(unsigned i = 0; i < world_objects.size(); i++){
        world_objects[i]->renderMinimap();
    }

    glDisable(GL_BLEND);
    glPopMatrix();
}

void Minimap::update(void){

}

